#include<iostream>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
LL n;
int main()
{
	while (cin >> n) {
		n %= mod;
		LL ans = (n % mod) * (n % mod + 1) % mod;
		ans = ans * (LL)(2 * n % mod + 1) / 6;
		cout << ans << endl;
	}
	return 0;
}